﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _0160929
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        int step = 5;
        bool isGo = true;
        private void button1_Click(object sender, EventArgs e)
        {
            
            timer1.Enabled = isGo;
            if (!isGo)
            {
                isGo = true;
                button1.Text = "Go";
            }
            else {
                isGo = false;
                button1.Text = "Stop";
            }
            
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            int x = label1.Location.X;
            label1.Left = x + step;
            if (label1.Location.X > this.Width || label1.Location.X < 0 - label1.Width) 
            {
                step = -step;
            }
            if (step > 0)
            {
                label1.ImageIndex = 0;
            }
            else
            {
                label1.ImageIndex = 1;
            }
        }
    }
}